import { Node, NodeSpace } from "cc";
import { EVector3 } from "../../engine/Math";
import MathHelper from "../../cfw/tools/MathHelper";


export class MoveToTarget {
    protected time: number = 0;
    protected dis: EVector3 = new EVector3();
    protected moveDirection: EVector3 = new EVector3();
    protected self: Node

    protected _speed: number = 4;

    setTarget(s: Node) {
        this.self = s;
    }

    setSpeed(s: number) {
        this._speed = s;
    }
    //水平移动
    updateH(deltaTime: number) {
        MathHelper.multiplyNumberOut(this.moveDirection, this.getSpeed() * deltaTime, this.dis)
        this.self.translate(this.dis, NodeSpace.LOCAL);
    }
    updateState(dt: number) {
        this.updateH(dt);

    }
    getSpeed() {
        return this._speed;
    }
}